<?php

// Builds the $wireframes array
require 'wireframes.php';

// Set a custom error handler
require 'errors.php';

// Find out the current wireframe
function getWireframe() {
    if(isset($_GET['wireframe'])) {
        $currentWireframe = $_GET['wireframe'];
    }
    return $currentWireframe;
}

function getWireframeName($wireframes) {
    $currentWireframe = getWireframe();
    return $wireframes[$currentWireframe]['name'];
}

// Build all current wireframes
function buildWireframes() {
    $wireframe = getWireframe();
    if($wireframe) {
        include 'wireframes/' . $wireframe . '.htm';
    }
}

// Generate a menu of wireframes
function buildWireframeMenu($wireframes) {
    $menu = "<ul>";
    foreach($wireframes as $wireframe => $data) {
        // If current, add the class
        if($wireframe == getWireframe()) {
            $menuItem = "<li class='current'>";
        }
        else {
            $menuItem = "<li>";
        }
        $menuItem .= "<a href='index.php?wireframe=$wireframe'>" 
            . $data['name'] 
            . "</a>"
            . "</li>";
        $menu .= $menuItem;
    }
    $menu .= "</ul>";
    return $menu;
}

